package com.advam;

import com.advam.storedpan.v2.storedpan.InsertRequest;
import com.advam.storedpan.v2.storedpan.InsertResponse;
import com.advam.storedpan.v2.storedpan.LinkTestRequest;
import com.advam.storedpan.v2.storedpan.LinkTestResponse;

public class Test {
    public static void main(String[] args){
        boolean isLive=true;
        String sandbox="https://demo-gateway.advam.com/stored_pan/V2/soap.php";
        String live="https://gateway.advam.com/stored_pan/V2/soap.php";
        
        StoredPANClient client=new StoredPANClient();
        StoredPANPortType portType;
        if(isLive){
            portType=client.getStoredPANPort(live);
        }else{
            portType=client.getStoredPANPort(sandbox);
        }
        
        LinkTestRequest linkRequest=new LinkTestRequest();
        LinkTestResponse linkResponse = portType.linkTest(linkRequest);
        out("!!!-->"+linkResponse.isSuccess());
        
        InsertRequest insertRequest=new InsertRequest();
        if(isLive){
            insertRequest.setAdvamAccount("xx");
            insertRequest.setOperatorUsername("xx");
            insertRequest.setOperatorPassword("xx");
        }else{
            insertRequest.setAdvamAccount("xx");
            insertRequest.setOperatorUsername("xx");
            insertRequest.setOperatorPassword("xx");
        }
        
        
        insertRequest.setPrimaryAccountNumber("4388576149246940");
        insertRequest.setExpiryMonth("12");
        insertRequest.setExpiryYear("14");
        insertRequest.setCardHolderName("fn ln");
        InsertResponse insertResponse=portType.insert(insertRequest);
        out("Env-- "+(isLive? "Live" : "Sandbox"));
        out("isSuccess="+insertResponse.isSuccess());
        out("ResponseCode="+insertResponse.getResponseCode());
        out("ResponseText="+insertResponse.getResponseText());
        out("PanId="+insertResponse.getPanId());
    }
    
    public static void out(Object obj){
        System.out.println(obj);
    }
}
